Conditions | 3 |
Total Lines | 168 |
Code Lines | 138 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | import { StaticQuery, graphql } from "gatsby"; |
||
252 | renderPlayerGamesFull = () => { |
||
253 | if (this.state.loading === false && this.state.data) { |
||
254 | const { gameReports = [] } = this.state.data; |
||
255 | |||
256 | return ( |
||
257 | <Card |
||
258 | className={`player-detail__games`} |
||
259 | title="Wedstrijden" |
||
260 | hasTable={true} |
||
261 | > |
||
262 | <table |
||
263 | className={`player-detail__games__table responsive-card-table`} |
||
264 | > |
||
265 | <thead> |
||
266 | <tr> |
||
267 | <th |
||
268 | className={`player-detail__column player-detail__column--string`} |
||
269 | > |
||
270 | Team |
||
271 | </th> |
||
272 | <th |
||
273 | className={`player-detail__column player-detail__column--string`} |
||
274 | > |
||
275 | Type |
||
276 | </th> |
||
277 | <th |
||
278 | className={`player-detail__column player-detail__column--string`} |
||
279 | > |
||
280 | Datum |
||
281 | </th> |
||
282 | <th |
||
283 | className={`player-detail__column player-detail__column--number`} |
||
284 | > |
||
285 | <span title="Thuis/uit">H/A</span> |
||
286 | </th> |
||
287 | <th |
||
288 | className={`player-detail__column player-detail__column--score`} |
||
289 | > |
||
290 | Score |
||
291 | </th> |
||
292 | <th |
||
293 | className={`player-detail__column player-detail__column--string`} |
||
294 | > |
||
295 | Tegenstander |
||
296 | </th> |
||
297 | <th |
||
298 | className={`player-detail__column player-detail__column--number`} |
||
299 | > |
||
300 | <img |
||
301 | src={iconCardYellow} |
||
302 | title="Gele kaart" |
||
303 | alt="Gele kaart" |
||
304 | className="player-detail__stats--header_icon" |
||
305 | /> |
||
306 | </th> |
||
307 | <th |
||
308 | className={`player-detail__column player-detail__column--number`} |
||
309 | > |
||
310 | <img |
||
311 | src={iconCardRed} |
||
312 | title="Rode kaart" |
||
313 | alt="Rode kaart" |
||
314 | className="player-detail__stats--header_icon" |
||
315 | /> |
||
316 | </th> |
||
317 | <th |
||
318 | className={`player-detail__column player-detail__column--number`} |
||
319 | > |
||
320 | <img |
||
321 | src={iconGoal} |
||
322 | title="Doelpunten gescoord" |
||
323 | alt="Rode kaart" |
||
324 | className="player-detail__stats--header_icon" |
||
325 | /> |
||
326 | </th> |
||
327 | <th |
||
328 | className={`player-detail__column player-detail__column--number`} |
||
329 | > |
||
330 | <span title="Minuten gespeeld"> |
||
331 | <Icon icon="fa-clock-o" /> |
||
332 | </span> |
||
333 | </th> |
||
334 | </tr> |
||
335 | </thead> |
||
336 | <tbody> |
||
337 | {gameReports.map(function (game) { |
||
338 | return ( |
||
339 | <tr> |
||
340 | <td |
||
341 | data-label="Team" |
||
342 | className={`player-detail__column player-detail__column--string`} |
||
343 | > |
||
344 | {game.team.replace(`Voetbal : `, ``)} |
||
345 | </td> |
||
346 | <td |
||
347 | data-label="Type" |
||
348 | className={`player-detail__column player-detail__column--string`} |
||
349 | > |
||
350 | {game.competition} |
||
351 | </td> |
||
352 | <td |
||
353 | data-label="Datum" |
||
354 | className={`player-detail__column player-detail__column--string`} |
||
355 | > |
||
356 | {moment(game.date).format(`DD/MM/YYYY`)} |
||
357 | </td> |
||
358 | <td |
||
359 | data-label="Thuis/uit" |
||
360 | className={`player-detail__column player-detail__column--number`} |
||
361 | > |
||
362 | {game.home ? ( |
||
363 | <span |
||
364 | className={`player-detail__games__home`} |
||
365 | title="Thuiswedstrijd" |
||
366 | > |
||
367 | <Icon icon="fa-home" alt="Thuiswedstrijd" /> |
||
368 | </span> |
||
369 | ) : ( |
||
370 | <span |
||
371 | className={`player-detail__games__away`} |
||
372 | title="Uitwedstrijd" |
||
373 | > |
||
374 | <Icon icon="fa-bus" alt="Uitwedstrijd" /> |
||
375 | </span> |
||
376 | )} |
||
377 | </td> |
||
378 | <td |
||
379 | data-label="Score" |
||
380 | className={`player-detail__column player-detail__column--score`} |
||
381 | > |
||
382 | {game.goalsHomeTeam} - {game.goalsAwayTeam} |
||
383 | </td> |
||
384 | <td |
||
385 | data-label="Tegenstander" |
||
386 | className={`player-detail__column player-detail__column--string`} |
||
387 | > |
||
388 | {game.opponent} |
||
389 | </td> |
||
390 | <td |
||
391 | data-label="Gele kaart(en)" |
||
392 | className={`player-detail__column player-detail__column--number`} |
||
393 | > |
||
394 | {game.yellowCards} |
||
395 | </td> |
||
396 | <td |
||
397 | data-label="Rode kaart(en)" |
||
398 | className={`player-detail__column player-detail__column--number`} |
||
399 | > |
||
400 | {game.redCards} |
||
401 | </td> |
||
402 | <td |
||
403 | data-label="Doelpunten" |
||
404 | className={`player-detail__column player-detail__column--number`} |
||
405 | > |
||
406 | {game.goals} |
||
407 | </td> |
||
408 | <td |
||
409 | data-label="Speeltijd" |
||
410 | className={`player-detail__column player-detail__column--number`} |
||
411 | > |
||
412 | {game.minutesPlayed}' |
||
413 | </td> |
||
414 | </tr> |
||
415 | ); |
||
416 | })} |
||
417 | </tbody> |
||
418 | </table> |
||
419 | </Card> |
||
420 | ); |
||
519 |